package com.py.credit.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.service.CollectionFormService;

/**
 * @author jicm 归集表单数据统计
 */
@RestController
@RequestMapping(value = "/dataFormShedule")
public class DataFormShedule {

	@Autowired
	private CollectionFormService collectionFormService;

	/**
	 * 
	 * @api {get} /dataFormShedule/taskRun.do 总体数据归集
	 * @apiName run
	 * @apiVersion 0.0.1
	 * @apiGroup 归集表单
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 */
	@RequestMapping("/taskRun")
	public RestServiceResult<Object> run() {
		RestServiceResult<Object> result = new RestServiceResult<Object>();
		try {
			collectionFormService.collectData();
			return result;
		} catch (Exception e) {
			result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("总体数据归集异常！");
			ExceptionLogger.error("DataFormShedule#run", "总体数据归集异常！ERROR:" + e.getMessage(), e);
			return result;
		}
	}
}
